<template>
    <div class="login-bg">
      <div class="login-wrap">
        <img src="../assets/LogoWhite.png" alt="">
        <div class="login-img">
          <p><img src="../assets/images/chenggong-1.png" alt=""></p>
          <h5>登录成功</h5>
        </div>
      </div>
    </div>
  </template>
  <script>
  // import {mapActions} from 'vuex';
  // import {loginData,tokenData} from '../api/user/index'
  import {request} from "../assets/js/utils/request";
  // import { Encrypt, Decrypt } from '@/assets/js/commonAse'
  export default {
    name: 'login',
    data() {
      return{
        pageUrl: ''
      }
    },
    created() {
      this.getUserInfo()
    },
    methods: {
      getUserInfo() {
        let code = this.$route.query.tk
        // let token = this.$encryptAES(code)
        this.$store.commit('setToken', code)
        sessionStorage.setItem('token', code)
        let loginTime = new Date().getTime()
        sessionStorage.setItem('startTime',loginTime)
        document.cookie = `XSRF-TOKEN=${code}`
        request({
            url: '/jaccountReturn.jsp?txtAction=getUserInfo',
            method: 'get'
        }).then(res => {
            // console.log(res,'ree')
            if(res.code == 200) {
              let userInfo = JSON.stringify(res.data.user)
              let rightCodes = res.data.rightCodes.length > 0 ? JSON.stringify(res.data.rightCodes) : []
              // let rightCodes = this.$encryptAES(str)
              this.$store.commit('setUserInfo', userInfo)
              this.$store.commit('setRightCodes', rightCodes)
              sessionStorage.setItem('userInfo',userInfo)
              sessionStorage.setItem('rightCodes',rightCodes)
              let authority = res.data.rightCodes
              if(authority.length > 0) {
                this.$router.push({ path: this.redirect || '/home' })
              } else {
                this.$router.push('/noPage')
              }
            }
        })
      }
    }
  }
  </script>
  <style lang="less" scoped>
  .login-bg{
    width:100%;
    height: 100vh;
    padding-top: 50px;
    position: relative;
    background: url("../assets/images/login-bg.jpg");
    background-size: 100% auto;
    .login-img{
      // width: 300px;
      // height: 300px;
      // text-align: center;
      // line-height: 300px;
      // border-radius: 10px;
      margin: 30px auto;
      position: relative;
      img{
        position: relative;
        vertical-align: middle;
        // z-index: 10;
        // width: 700px;
      }
      .shadow{
        position: absolute;
        left: 25px;
        bottom: 10px;
        width: 600px;
        height: 30px;
        border-radius: 50px;
        background: rgba(0,0,0,0.1);
        box-shadow: 2px 2px 25px rgba(0,0,0,0.5);
      }
    }
  }
    
  .login-wrap{
    width: 1300px;
    padding-top: 50px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    h5{
      font-size: 30px;
      color: #fff;
      margin: 30px 0;
    }
    .login-box{
      position: relative;
      width: 380px;
      height: 450px;
      margin-top: 30px;
      margin-right: 50px;
      padding: 30px;
      background: rgba(255,255,255,0.2);
      border-radius: 8px;
      .logo{
        text-align: center;
        margin: 20px 0;
        img{
          vertical-align: middle;
        }
        p{
          color: #fff;
          font-size: 24px;
          margin-left: 10px;
        }
      }
    }
    /deep/.login {
      h4{
        font-size: 16px;
        color: #fff;
        margin: 20px 0;
      }
      .item{
        margin-bottom: 25px;
        .el-input {
          width: 100%;
          .el-input__inner{
            width: 100%;
            border: none;
            background: #ffffff;
            border-radius: 10px;
            height: 38px;
            font-size:14px;
            outline: none;
          }
        }
      }
      button{
        width: 320px;
        height: 38px;
        border-radius: 10px;
        padding: 10px 0;
        border: 1px solid #07b3d0;
        background: #07b3d0;
        color: #fff;
        line-height: 18px;
      }
    }
  }
  </style>